package m.jclecai.com.adapter;

import android.content.Context;
import android.graphics.Color;
import android.text.Html;
import android.text.Spanned;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseExpandableListAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.text.DecimalFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;

import m.jclecai.com.R;
import m.jclecai.com.bean.ZqHHItem;
import m.jclecai.com.dialog.HHDialog;
import m.jclecai.com.listener.NotifyTextViewSetChanged;
import m.jclecai.com.utils.Utils;
import m.jclecai.com.utils.http.FastOk;

/**
 *
 * 混合投注
 * Created by hp on 2017/3/23.
 *
 */
@Deprecated
public class ExpandableHHAdapter extends BaseExpandableListAdapter {

    private Context context;
    private List<String> groups;
    List<List<ZqHHItem>> lists;
    NotifyTextViewSetChanged changed;
    private HHDialog hhDialog;
    DecimalFormat df = new DecimalFormat("#.00");
    public ExpandableHHAdapter(){

    }
    public ExpandableHHAdapter(Context context, List<String> groups,List<List<ZqHHItem>> lists,NotifyTextViewSetChanged changed){
        this.context=context;
        this.groups=groups;
        this.lists=lists;
        this.changed=changed;

    }
    @Override
    public int getGroupCount() {
        return groups.size();
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return lists.get(groupPosition).size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return groups.get(groupPosition);
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return lists.get(groupPosition).get(childPosition);
    }

    @Override
    public long getGroupId(int groupPosition) {
        return groupPosition;
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return childPosition;
    }

    @Override
    public boolean hasStableIds() {
        return false;
    }

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        GroupViewHolder groupViewHolder;
        if(convertView==null){
            convertView=View.inflate(context, R.layout.item_parent,null);
            groupViewHolder=new GroupViewHolder(convertView);
            convertView.setTag(groupViewHolder);
        }else {
            groupViewHolder = (GroupViewHolder) convertView.getTag();
        }
        groupViewHolder.list_item_parent_title.setText(groups.get(groupPosition));

        if(isExpanded){
            groupViewHolder.list_item_parent_icon.setImageResource(R.drawable.cz);
        }else {
            groupViewHolder.list_item_parent_icon.setImageResource(R.drawable.d0);
        }
        return convertView;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        ChlidViewHolder chlidViewHolder;
        if(convertView==null){
            convertView=View.inflate(context,R.layout.item_zq_hh,null);
            chlidViewHolder=new ChlidViewHolder(convertView);
            convertView.setTag(chlidViewHolder);
        }else {
            chlidViewHolder= (ChlidViewHolder) convertView.getTag();
        }
        final ZqHHItem item = (ZqHHItem) getChild(groupPosition,childPosition);
        final String[] codes = item.getCodes();

        final List<String[]> lists = FastOk.getList(codes[16], String[].class);


        chlidViewHolder.away_team_name.setText(Html.fromHtml(codes[4]));
        chlidViewHolder.home_team_name.setText(Html.fromHtml(codes[3]));
        chlidViewHolder.item_name.setText(codes[2]);//世界杯预选赛
        chlidViewHolder.item_time.setText(codes[7].substring(5, 16)+"\n"+codes[1]);

        chlidViewHolder.odd_home.setText("主胜"+df.format(Double.parseDouble(lists.get(0)[0])));
        chlidViewHolder.odd_away.setText("平"+df.format(Double.parseDouble(lists.get(0)[1])));
        chlidViewHolder.odd_draw.setText("主负"+df.format(Double.parseDouble(lists.get(0)[2])));

        chlidViewHolder.odd_home_rang.setText("让胜"+df.format(Double.parseDouble(lists.get(1)[0])));
        chlidViewHolder.odd_away_rang.setText("让平"+df.format(Double.parseDouble(lists.get(1)[1])));
        chlidViewHolder.odd_draw_rang.setText("让负"+df.format(Double.parseDouble(lists.get(1)[2])));
        chlidViewHolder.rang_num.setText(codes[5]);

        if (item.getOdd_select().containsKey("3")) {
            chlidViewHolder.odd_home.setTextColor(Color.WHITE);
            chlidViewHolder.odd_home.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
        } else {
            chlidViewHolder.odd_home.setTextColor(Color.BLACK);
            chlidViewHolder.odd_home.setBackgroundColor(Color.WHITE);
        }

        if (item.getOdd_select().containsKey("1")) {
            chlidViewHolder.odd_away.setTextColor(Color.WHITE);
            chlidViewHolder.odd_away.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
        } else {
            chlidViewHolder.odd_away.setTextColor(Color.BLACK);
            chlidViewHolder.odd_away.setBackgroundColor(Color.WHITE);
        }

        if (item.getOdd_select().containsKey("0")) {
            chlidViewHolder.odd_draw.setTextColor(Color.WHITE);
            chlidViewHolder.odd_draw.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
        } else {
            chlidViewHolder.odd_draw.setTextColor(Color.BLACK);
            chlidViewHolder.odd_draw.setBackgroundColor(Color.WHITE);
        }

        if (item.getOdd_select_r().containsKey("3")) {
            chlidViewHolder.odd_home_rang.setTextColor(Color.WHITE);
            chlidViewHolder.odd_home_rang.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
        } else {
            chlidViewHolder.odd_home_rang.setTextColor(Color.BLACK);
            chlidViewHolder.odd_home_rang.setBackgroundColor(Color.WHITE);
        }

        if (item.getOdd_select_r().containsKey("1")) {
            chlidViewHolder.odd_away_rang.setTextColor(Color.WHITE);
            chlidViewHolder.odd_away_rang.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
        } else {
            chlidViewHolder.odd_away_rang.setTextColor(Color.BLACK);
            chlidViewHolder.odd_away_rang.setBackgroundColor(Color.WHITE);
        }

        if (item.getOdd_select_r().containsKey("0")) {
            chlidViewHolder.odd_draw_rang.setTextColor(Color.WHITE);
            chlidViewHolder.odd_draw_rang.setBackgroundColor(android.graphics.Color.parseColor("#FF0026"));
        } else {
            chlidViewHolder.odd_draw_rang.setTextColor(Color.BLACK);
            chlidViewHolder.odd_draw_rang.setBackgroundColor(Color.WHITE);
        }


        chlidViewHolder.odd_home.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (item.getOdd_select().containsKey("3")) {
                    item.setSelectNum(item.getSelectNum()-1);
                    item.getOdd_select().remove("3");

                    item.getOdd_sp().remove(lists.get(0)[0]);
                } else {
                    item.getOdd_select().put("3", "主胜");
                    item.setSelectNum(item.getSelectNum()+1);
                    String s = lists.get(0)[0];
                    item.getOdd_sp().add(lists.get(0)[0]);
                }
                addItem(item);
            }
        });
        chlidViewHolder.odd_away.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (item.getOdd_select().containsKey("1")) {
                    item.setSelectNum(item.getSelectNum()-1);
                    item.getOdd_select().remove("1");
                    item.getOdd_sp().remove(lists.get(0)[1]);
                } else {
                    item.getOdd_select().put("1","平");
                    item.setSelectNum(item.getSelectNum()+1);
                    item.getOdd_sp().add(lists.get(0)[1]);
                }
                addItem(item);
            }
        });
        chlidViewHolder.odd_draw.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (item.getOdd_select().containsKey("0")) {
                    item.setSelectNum(item.getSelectNum()-1);
                    item.getOdd_select().remove("0");
                    item.getOdd_sp().remove(lists.get(0)[2]);
                } else {
                    item.getOdd_select().put("0","主负");
                    item.setSelectNum(item.getSelectNum()+1);
                    item.getOdd_sp().add(lists.get(0)[2]);
                }
                addItem(item);
            }
        });

        chlidViewHolder.odd_home_rang.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (item.getOdd_select_r().containsKey("3")) {
                    item.setSelectNum(item.getSelectNum()-1);
                    item.getOdd_select_r().remove("3");
                    item.getOdd_rsp().remove(lists.get(1)[0]);
                } else {
                    item.getOdd_select_r().put("3","让胜");
                    item.setSelectNum(item.getSelectNum()+1);
                    item.getOdd_rsp().add(lists.get(1)[0]);
                }
                addItem(item);
            }
        });
        chlidViewHolder.odd_away_rang.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (item.getOdd_select_r().containsKey("1")) {
                    item.setSelectNum(item.getSelectNum()-1);
                    item.getOdd_select_r().remove("1");
                    item.getOdd_rsp().remove(lists.get(1)[1]);
                } else {
                    item.getOdd_select_r().put("1","让平");
                    item.setSelectNum(item.getSelectNum()+1);
                    item.getOdd_rsp().add(lists.get(1)[1]);
                }
                addItem(item);
            }
        });
        chlidViewHolder.odd_draw_rang.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View arg0) {
                if (item.getOdd_select_r().containsKey("0")) {
                    item.setSelectNum(item.getSelectNum()-1);
                    item.getOdd_select_r().remove("0");
                    item.getOdd_rsp().remove(lists.get(1)[2]);
                } else {
                    item.getOdd_select_r().put("0","让负");
                    item.setSelectNum(item.getSelectNum()+1);
                    item.getOdd_rsp().add(lists.get(1)[2]);
                }
                addItem(item);
            }
        });
        chlidViewHolder.hh_select.setTag(item);
        chlidViewHolder.hh_select.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                // TODO Auto-generated method stub
                hhDialog = new HHDialog(context, R.style.delete_dialog, new HHDialog.HHDialogListener() {

                    @Override
                    public void onClick(View view) {
                        // TODO Auto-generated method stub
                        switch (view.getId()) {
                            case R.id.dialog_cancel:
                                hhDialog.dismiss();
                                break;
                            case R.id.dialog_confirm:
                                hhDialog.dismiss();
                                break;
                            case R.id.dialog_odd_home:
                                changeTextState(hhDialog.oddHome, item.getOdd_select(), "主胜", lists.get(0)[0], "3", item);
                                break;
                            case R.id.dialog_odd_away:
                                changeTextState(hhDialog.oddAway, item.getOdd_select(), "平", lists.get(0)[0], "1", item);
                                break;
                            case R.id.dialog_odd_draw:
                                changeTextState(hhDialog.oddDraw, item.getOdd_select(), "主负", lists.get(0)[0], "0", item);
                                break;
                            case R.id.dialog_odd_home_rang:
                                changeTextState(hhDialog.oddHomeR, item.getOdd_select_r(), "让胜", lists.get(0)[0], "3", item);
                                break;
                            case R.id.dialog_odd_away_rang:
                                changeTextState(hhDialog.oddAwayR, item.getOdd_select_r(), "让平", lists.get(0)[0], "1", item);
                                break;
                            case R.id.dialog_odd_draw_rang:
                                changeTextState(hhDialog.oddDrawR, item.getOdd_select_r(), "让负", lists.get(0)[0], "0", item);
                                break;
                            case R.id.dialog_odd_ss:
                                changeTextState(hhDialog.oddss, item.getOdd_select_bqc(), "胜胜", lists.get(4)[0], "3-3", item);
                                break;
                            case R.id.dialog_odd_sp:
                                changeTextState(hhDialog.oddsp, item.getOdd_select_bqc(), "胜平", lists.get(4)[1], "3-1", item);
                                break;
                            case R.id.dialog_odd_sf:
                                changeTextState(hhDialog.oddsf, item.getOdd_select_bqc(), "胜负", lists.get(4)[2], "3-0", item);
                                break;
                            case R.id.dialog_odd_ps:
                                changeTextState(hhDialog.oddps, item.getOdd_select_bqc(), "平胜", lists.get(4)[3], "1-3", item);
                                break;
                            case R.id.dialog_odd_pp:
                                changeTextState(hhDialog.oddpp, item.getOdd_select_bqc(), "平平", lists.get(4)[4], "1-1", item);
                                break;
                            case R.id.dialog_odd_pf:
                                changeTextState(hhDialog.oddpf, item.getOdd_select_bqc(), "平负", lists.get(4)[5], "1-0", item);
                                break;
                            case R.id.dialog_odd_fs:
                                changeTextState(hhDialog.oddfs, item.getOdd_select_bqc(), "负胜", lists.get(4)[6], "0-3", item);
                                break;
                            case R.id.dialog_odd_fp:
                                changeTextState(hhDialog.oddfp, item.getOdd_select_bqc(), "负平", lists.get(4)[7], "0-1", item);
                                break;
                            case R.id.dialog_odd_ff:
                                changeTextState(hhDialog.oddff, item.getOdd_select_bqc(), "负负", lists.get(4)[8], "0-0", item);
                                break;
                            case R.id.dialog_odd_0:
                                changeTextState(hhDialog.oddZero, item.getOdd_select_jqs(), "0", lists.get(2)[0], "0", item);
                                break;
                            case R.id.dialog_odd_1:
                                changeTextState(hhDialog.oddOne, item.getOdd_select_jqs(), "1", lists.get(2)[1], "1", item);
                                break;
                            case R.id.dialog_odd_2:
                                changeTextState(hhDialog.oddTwo, item.getOdd_select_jqs(), "2", lists.get(2)[2], "2", item);
                                break;
                            case R.id.dialog_odd_3:
                                changeTextState(hhDialog.oddThree, item.getOdd_select_jqs(), "3", lists.get(2)[3], "3", item);
                                break;
                            case R.id.dialog_odd_4:
                                changeTextState(hhDialog.oddFour, item.getOdd_select_jqs(), "4", lists.get(2)[4], "4", item);
                                break;
                            case R.id.dialog_odd_5:
                                changeTextState(hhDialog.oddFive, item.getOdd_select_jqs(), "5", lists.get(2)[5], "5", item);
                                break;
                            case R.id.dialog_odd_6:
                                changeTextState(hhDialog.oddSix, item.getOdd_select_jqs(), "6", lists.get(2)[6], "6", item);
                                break;
                            case R.id.dialog_odd_7:
                                changeTextState(hhDialog.oddSeven, item.getOdd_select_jqs(), "7+", lists.get(2)[7], "7", item);
                                break;
                            case R.id.dialog_odd_10:
                                changeTextState(hhDialog.odd10, item.getOdd_select_cbf(), "1:0", lists.get(3)[0], "1:0", item);
                                break;
                            case R.id.dialog_odd_20:
                                changeTextState(hhDialog.odd20, item.getOdd_select_cbf(), "2:0", lists.get(3)[1], "2:0", item);
                                break;
                            case R.id.dialog_odd_21:
                                changeTextState(hhDialog.odd21, item.getOdd_select_cbf(), "2:1", lists.get(3)[2], "2:1", item);
                                break;
                            case R.id.dialog_odd_30:
                                changeTextState(hhDialog.odd30, item.getOdd_select_cbf(), "3:0", lists.get(3)[3], "3:0", item);
                                break;
                            case R.id.dialog_odd_31:
                                changeTextState(hhDialog.odd31, item.getOdd_select_cbf(), "3:1", lists.get(3)[4], "3:1", item);
                                break;
                            case R.id.dialog_odd_32:
                                changeTextState(hhDialog.odd32, item.getOdd_select_cbf(), "3:2", lists.get(3)[5], "3:2", item);
                                break;
                            case R.id.dialog_odd_40:
                                changeTextState(hhDialog.odd40, item.getOdd_select_cbf(), "4:0", lists.get(3)[6], "4:0", item);
                                break;
                            case R.id.dialog_odd_41:
                                changeTextState(hhDialog.odd41, item.getOdd_select_cbf(), "4:1", lists.get(3)[7], "4:1", item);
                                break;
                            case R.id.dialog_odd_42:
                                changeTextState(hhDialog.odd42, item.getOdd_select_cbf(), "4:2", lists.get(3)[8], "4:2", item);
                                break;
                            case R.id.dialog_odd_50:
                                changeTextState(hhDialog.odd50, item.getOdd_select_cbf(), "5:0", lists.get(3)[9], "5:0", item);
                                break;
                            case R.id.dialog_odd_51:
                                changeTextState(hhDialog.odd51, item.getOdd_select_cbf(), "5:1", lists.get(3)[10], "5:1", item);
                                break;
                            case R.id.dialog_odd_52:
                                changeTextState(hhDialog.odd52, item.getOdd_select_cbf(), "5:2", lists.get(3)[11], "5:2", item);
                                break;
                            case R.id.dialog_odd_99:
                                changeTextState(hhDialog.odd99, item.getOdd_select_cbf(), "胜其他", lists.get(3)[12], "9:0", item);
                                break;
                            case R.id.dialog_odd_00:
                                changeTextState(hhDialog.odd00, item.getOdd_select_cbf(), "0:0", lists.get(3)[13], "0:0", item);
                                break;
                            case R.id.dialog_odd_11:
                                changeTextState(hhDialog.odd11, item.getOdd_select_cbf(), "1:1", lists.get(3)[14], "1:1", item);
                                break;
                            case R.id.dialog_odd_22:
                                changeTextState(hhDialog.odd22, item.getOdd_select_cbf(), "2:2", lists.get(3)[15], "2:2", item);
                                break;
                            case R.id.dialog_odd_33:
                                changeTextState(hhDialog.odd33, item.getOdd_select_cbf(), "3:3", lists.get(3)[16], "3:3", item);
                                break;
                            case R.id.dialog_odd_19:
                                changeTextState(hhDialog.odd19, item.getOdd_select_cbf(), "平其他", lists.get(3)[17], "9:9", item);
                                break;
                            case R.id.dialog_odd_01:
                                changeTextState(hhDialog.odd01, item.getOdd_select_cbf(), "0:1", lists.get(3)[18], "0:1", item);
                                break;
                            case R.id.dialog_odd_02:
                                changeTextState(hhDialog.odd02, item.getOdd_select_cbf(), "0:2", lists.get(3)[19], "0:2", item);
                                break;
                            case R.id.dialog_odd_12:
                                changeTextState(hhDialog.odd12, item.getOdd_select_cbf(), "1:2", lists.get(3)[20], "1:2", item);
                                break;
                            case R.id.dialog_odd_03:
                                changeTextState(hhDialog.odd03, item.getOdd_select_cbf(), "0:3", lists.get(3)[21], "0:3", item);
                                break;
                            case R.id.dialog_odd_13:
                                changeTextState(hhDialog.odd13, item.getOdd_select_cbf(), "1:3", lists.get(3)[22], "1:3", item);
                                break;
                            case R.id.dialog_odd_23:
                                changeTextState(hhDialog.odd23, item.getOdd_select_cbf(), "2:3", lists.get(3)[23], "2:3", item);
                                break;
                            case R.id.dialog_odd_04:
                                changeTextState(hhDialog.odd04, item.getOdd_select_cbf(), "0:4", lists.get(3)[24], "0:3", item);
                                break;
                            case R.id.dialog_odd_14:
                                changeTextState(hhDialog.odd14, item.getOdd_select_cbf(), "1:4", lists.get(3)[25], "1:4", item);
                                break;
                            case R.id.dialog_odd_24:
                                changeTextState(hhDialog.odd24, item.getOdd_select_cbf(), "2:4", lists.get(3)[26], "2:4", item);
                                break;
                            case R.id.dialog_odd_05:
                                changeTextState(hhDialog.odd05, item.getOdd_select_cbf(), "0:5", lists.get(3)[27], "0:4", item);
                                break;
                            case R.id.dialog_odd_15:
                                changeTextState(hhDialog.odd15, item.getOdd_select_cbf(), "1:5", lists.get(3)[28], "1:5", item);
                                break;
                            case R.id.dialog_odd_25:
                                changeTextState(hhDialog.odd25, item.getOdd_select_cbf(), "2:5", lists.get(3)[29], "2:5", item);
                                break;
                            case R.id.dialog_odd_09:
                                changeTextState(hhDialog.odd09, item.getOdd_select_cbf(), "负其他", lists.get(3)[30], "0:9", item);
                                break;
                        }
                    }
                });
                creatTextView(R.id.dialog_home_team, codes[3]);
                creatTextView(R.id.dialog_draw_team, codes[4]);
                creatTextView(R.id.dialog_odd_home, item.getOdd_select().containsKey("3") ? true : false, "主胜", lists.get(0)[0]);
                creatTextView(R.id.dialog_odd_away, item.getOdd_select().containsKey("1") ? true : false, "平", lists.get(0)[1]);
                creatTextView(R.id.dialog_odd_draw, item.getOdd_select().containsKey("0") ? true : false, "主负", lists.get(0)[2] );
                creatTextView(R.id.dialog_odd_home_rang, item.getOdd_select_r().containsKey("3") ? true : false, "让胜", lists.get(1)[0]);
                creatTextView(R.id.dialog_odd_away_rang, item.getOdd_select_r().containsKey("1") ? true : false, "让平", lists.get(1)[1]);
                creatTextView(R.id.dialog_odd_draw_rang, item.getOdd_select_r().containsKey("0") ? true : false, "让负", lists.get(1)[2]);
                showNoData(R.id.dialog_odd_data, R.id.dialog_odd_data_close, codes[8].substring(0, 1));
                showNoData(R.id.dialog_odd_rang_data, R.id.dialog_odd_rang_data_close, codes[8].substring(4, 5));

                creatTextView(R.id.dialog_odd_ss, item.getOdd_select_bqc().containsKey("3-3")? true : false,"胜胜", lists.get(4)[0]);
                creatTextView(R.id.dialog_odd_sp, item.getOdd_select_bqc().containsKey("3-1")? true : false,"胜平", lists.get(4)[1]);
                creatTextView(R.id.dialog_odd_sf, item.getOdd_select_bqc().containsKey("3-0")? true : false,"胜负", lists.get(4)[2]);
                creatTextView(R.id.dialog_odd_ps, item.getOdd_select_bqc().containsKey("1-3")? true : false,"平胜", lists.get(4)[3]);
                creatTextView(R.id.dialog_odd_pp, item.getOdd_select_bqc().containsKey("1-1")? true : false,"平平", lists.get(4)[4]);
                creatTextView(R.id.dialog_odd_pf, item.getOdd_select_bqc().containsKey("1-0")? true : false,"平负", lists.get(4)[5]);
                creatTextView(R.id.dialog_odd_fs, item.getOdd_select_bqc().containsKey("0-3")? true : false,"负胜", lists.get(4)[6]);
                creatTextView(R.id.dialog_odd_fp, item.getOdd_select_bqc().containsKey("0-1")? true : false,"负平", lists.get(4)[7]);
                creatTextView(R.id.dialog_odd_ff, item.getOdd_select_bqc().containsKey("0-0")? true : false,"负负", lists.get(4)[8]);

                creatTextView(R.id.dialog_odd_0, item.getOdd_select_jqs().containsKey("0")? true : false,"0", lists.get(2)[0]);
                creatTextView(R.id.dialog_odd_1, item.getOdd_select_jqs().containsKey("1")? true : false,"1", lists.get(2)[1]);
                creatTextView(R.id.dialog_odd_2, item.getOdd_select_jqs().containsKey("2")? true : false,"2", lists.get(2)[2]);
                creatTextView(R.id.dialog_odd_3, item.getOdd_select_jqs().containsKey("3")? true : false,"3", lists.get(2)[3]);
                creatTextView(R.id.dialog_odd_4, item.getOdd_select_jqs().containsKey("4")? true : false,"4", lists.get(2)[4]);
                creatTextView(R.id.dialog_odd_5, item.getOdd_select_jqs().containsKey("5")? true : false,"5", lists.get(2)[5]);
                creatTextView(R.id.dialog_odd_6, item.getOdd_select_jqs().containsKey("6")? true : false,"6", lists.get(2)[6]);
                creatTextView(R.id.dialog_odd_7, item.getOdd_select_jqs().containsKey("7")? true : false,"7+", lists.get(2)[7]);

                creatTextView(R.id.dialog_odd_10, item.getOdd_select_cbf().contains("1:0")? true : false,"1:0", lists.get(3)[0]);
                creatTextView(R.id.dialog_odd_20, item.getOdd_select_cbf().contains("2:0")? true : false,"2:0", lists.get(3)[1]);
                creatTextView(R.id.dialog_odd_21, item.getOdd_select_cbf().contains("2:1")? true : false,"2:1", lists.get(3)[2]);
                creatTextView(R.id.dialog_odd_30, item.getOdd_select_cbf().contains("3:0")? true : false,"3:0", lists.get(3)[3]);
                creatTextView(R.id.dialog_odd_31, item.getOdd_select_cbf().contains("3:1")? true : false,"3:1", lists.get(3)[4]);
                creatTextView(R.id.dialog_odd_32, item.getOdd_select_cbf().contains("3:2")? true : false,"3:2", lists.get(3)[5]);
                creatTextView(R.id.dialog_odd_40, item.getOdd_select_cbf().contains("4:0")? true : false,"4:0", lists.get(3)[6]);
                creatTextView(R.id.dialog_odd_41, item.getOdd_select_cbf().contains("4:1")? true : false,"4:1", lists.get(3)[7]);
                creatTextView(R.id.dialog_odd_42, item.getOdd_select_cbf().contains("4:2")? true : false,"4:2", lists.get(3)[8]);
                creatTextView(R.id.dialog_odd_50, item.getOdd_select_cbf().contains("5:0")? true : false,"5:0", lists.get(3)[9]);
                creatTextView(R.id.dialog_odd_51, item.getOdd_select_cbf().contains("5:1")? true : false,"5:1", lists.get(3)[10]);
                creatTextView(R.id.dialog_odd_52, item.getOdd_select_cbf().contains("5:2")? true : false,"5:2", lists.get(3)[11]);
                creatTextView(R.id.dialog_odd_99, item.getOdd_select_cbf().contains("9:0")? true : false,"胜其他", lists.get(3)[12]);
                creatTextView(R.id.dialog_odd_00, item.getOdd_select_cbf().contains("0:0")? true : false,"0:0", lists.get(3)[13]);
                creatTextView(R.id.dialog_odd_11, item.getOdd_select_cbf().contains("1:1")? true : false,"1:1", lists.get(3)[14]);
                creatTextView(R.id.dialog_odd_22, item.getOdd_select_cbf().contains("2:2")? true : false,"2:2", lists.get(3)[15]);
                creatTextView(R.id.dialog_odd_33, item.getOdd_select_cbf().contains("3:3")? true : false,"3:3", lists.get(3)[16]);
                creatTextView(R.id.dialog_odd_19, item.getOdd_select_cbf().contains("9:9")? true : false,"平其他", lists.get(3)[17]);
                creatTextView(R.id.dialog_odd_01, item.getOdd_select_cbf().contains("0:1")? true : false,"0:1", lists.get(3)[18]);
                creatTextView(R.id.dialog_odd_02, item.getOdd_select_cbf().contains("0:2")? true : false,"0:2", lists.get(3)[19]);
                creatTextView(R.id.dialog_odd_12, item.getOdd_select_cbf().contains("1:2")? true : false,"1:2", lists.get(3)[20]);
                creatTextView(R.id.dialog_odd_03, item.getOdd_select_cbf().contains("0:3")? true : false,"0:3", lists.get(3)[21]);
                creatTextView(R.id.dialog_odd_13, item.getOdd_select_cbf().contains("1:3")? true : false,"1:3", lists.get(3)[22]);
                creatTextView(R.id.dialog_odd_23, item.getOdd_select_cbf().contains("2:3")? true : false,"2:3", lists.get(3)[23]);
                creatTextView(R.id.dialog_odd_04, item.getOdd_select_cbf().contains("0:4")? true : false,"0:4", lists.get(3)[24]);
                creatTextView(R.id.dialog_odd_14, item.getOdd_select_cbf().contains("1:4")? true : false,"1:4", lists.get(3)[25]);
                creatTextView(R.id.dialog_odd_24, item.getOdd_select_cbf().contains("2:4")? true : false,"2:4", lists.get(3)[26]);
                creatTextView(R.id.dialog_odd_05, item.getOdd_select_cbf().contains("0:5")? true : false,"0:5", lists.get(3)[27]);
                creatTextView(R.id.dialog_odd_15, item.getOdd_select_cbf().contains("1:5")? true : false,"1:5", lists.get(3)[28]);
                creatTextView(R.id.dialog_odd_25, item.getOdd_select_cbf().contains("2:5")? true : false,"2:5", lists.get(3)[29]);
                creatTextView(R.id.dialog_odd_09, item.getOdd_select_cbf().contains("0:9")? true : false,"负其他", lists.get(3)[30]);

                hhDialog.setCancelable(false);
                hhDialog.setCanceledOnTouchOutside(false);
                hhDialog.show();
            }
        });
        return convertView;
    }
    private void changeTextState(TextView view, HashMap<String, String> map, String name, String sp, String code, ZqHHItem item) {
        // TODO Auto-generated method stub
        if (map.containsKey(code)) {
            map.remove(code);
            Spanned spanned = Html.fromHtml(name+"<br><font color='#a09b85'>" + df.format(Double.parseDouble(sp))+"<font>");
            view.setText(spanned);
            view.setTextColor(Color.BLACK);
            view.setBackgroundColor(android.graphics.Color.parseColor("#f8f4eb"));
            item.setSelectNum(item.getSelectNum()-1);
        } else {
            map.put(code, name);
            Spanned spanned = Html.fromHtml(name+"<br>" + df.format(Double.parseDouble(sp)));
            view.setText(spanned);
            view.setTextColor(Color.WHITE);
            view.setBackgroundColor(android.graphics.Color.parseColor("#006bed"));
            item.setSelectNum(item.getSelectNum()+1);
        }
        addItem(item);
    }
    private void changeTextState(TextView view, HashSet<String> set, String name, String sp, String code, ZqHHItem item) {
        // TODO Auto-generated method stub
        if (set.contains(code)) {
            set.remove(code);
            Spanned spanned = Html.fromHtml(name+"<br><font color='#a09b85'>" + df.format(Double.parseDouble(sp))+"<font>");
            view.setText(spanned);
            view.setTextColor(Color.BLACK);
            view.setBackgroundColor(android.graphics.Color.parseColor("#f8f4eb"));
            item.setSelectNum(item.getSelectNum()-1);
        } else {
            set.add(code);
            Spanned spanned = Html.fromHtml(name+"<br>" + df.format(Double.parseDouble(sp)));
            view.setText(spanned);
            view.setTextColor(Color.WHITE);
            view.setBackgroundColor(android.graphics.Color.parseColor("#006bed"));
            item.setSelectNum(item.getSelectNum()+1);
        }
        addItem(item);
    }


    private void creatTextView(int resId,boolean isChecked,String name,String sp){
        TextView view = (TextView) hhDialog.getView().findViewById(resId);
        changeBg(view, isChecked,name,sp);
    }

    private void creatTextView(int resId, String text){
        TextView view = (TextView) hhDialog.getView().findViewById(resId);
        view.setText(text);
    }
    private void changeBg(TextView view, boolean isChecked,String name,String sp){
        if (isChecked) {
            Spanned spanned = Html.fromHtml(name+"<br>" + df.format(Double.parseDouble(sp)));
            view.setText(spanned);
            view.setTextColor(Color.WHITE);
            view.setBackgroundColor(android.graphics.Color.parseColor("#006bed"));
        } else {
            Spanned spanned = Html.fromHtml(name+"<br><font color='#a09b85'>" + df.format(Double.parseDouble(sp))+"<font>");
            view.setText(spanned);
            view.setTextColor(Color.BLACK);
            view.setBackgroundColor(android.graphics.Color.parseColor("#f8f4eb"));
        }
    }

    private void addItem(ZqHHItem item) {
        // TODO Auto-generated method stub
        if (item.getSelectNum() > 0) {
            if (!Utils.ZQ_HH_ITEM_LIST.contains(item)) {
                Utils.ZQ_HH_ITEM_LIST.add(item);
            }
        } else {
            if (Utils.ZQ_HH_ITEM_LIST.contains(item)) {
                Utils.ZQ_HH_ITEM_LIST.remove(item);
            }
        }
        notifyDataSetChanged();
        changed.onClickSetChangedText();
    }

    private void showNoData(int layoutId,int txtId,String num){
        TextView txtview = (TextView) hhDialog.getView().findViewById(txtId);
        LinearLayout layoutview = (LinearLayout) hhDialog.getView().findViewById(layoutId);
        if(num.equals("1")){
            layoutview.setVisibility(View.GONE);
            txtview.setVisibility(View.VISIBLE);
        }
    }
    @Override
    public boolean isChildSelectable(int groupPosition, int childPosition) {
        return false;
    }

    static class GroupViewHolder{
        private final TextView list_item_parent_title;
        private final ImageView list_item_parent_icon;

        public GroupViewHolder(View view){
            list_item_parent_title = (TextView) view.findViewById(R.id.list_item_parent_title);
            list_item_parent_icon = (ImageView) view.findViewById(R.id.list_item_parent_icon);
        }
    }
    static class ChlidViewHolder{
        private final TextView item_name;
        private final TextView item_time;
        private final TextView home_team_name;
        private final TextView rang_num;
        private final TextView away_team_name;
        private final TextView odd_home;
        private final TextView odd_away;
        private final TextView odd_draw;
        private final TextView odd_home_rang;
        private final TextView odd_away_rang;
        private final TextView odd_draw_rang;
        private final TextView hh_select;

        public ChlidViewHolder(View view){
            item_name = (TextView) view.findViewById(R.id.item_name);
            item_time = (TextView) view.findViewById(R.id.item_time);
            home_team_name = (TextView) view.findViewById(R.id.home_team_name);
            rang_num = (TextView) view.findViewById(R.id.rang_num);
            away_team_name = (TextView) view.findViewById(R.id.away_team_name);
            odd_home = (TextView) view.findViewById(R.id.odd_home);
            odd_away = (TextView) view.findViewById(R.id.odd_away);
            odd_draw = (TextView) view.findViewById(R.id.odd_draw);
            odd_home_rang = (TextView) view.findViewById(R.id.odd_home_rang);
            odd_away_rang = (TextView) view.findViewById(R.id.odd_away_rang);
            odd_draw_rang = (TextView) view.findViewById(R.id.odd_draw_rang);
            hh_select = (TextView) view.findViewById(R.id.hh_select);
        }
    }
}
